package aiku.numericalcontroloa.Controller.CompanyCulture;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.CompanyCulture.CommentDto;
import aiku.numericalcontroloa.Service.CompanyCulture.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 评论控制层
 * @Author 黄广庭
 * @Date 2024/1/10 16:53
 */
@RestController
@RequestMapping("/comment")
@Slf4j
public class CommentCont {
    private final CommentService commentService;

    public CommentCont(CommentService commentService) {
        this.commentService = commentService;
    }

    /**
     * 发表评论
     * @param commentDto
     * @return
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody CommentDto commentDto){
        return commentService.addComment(commentDto);
    }


    /**
     * 删除个人评论
     * @param commentDto
     * @return
     */
    @PostMapping("/deleteUserComment")
    public Result deleteUserComment(@RequestBody CommentDto commentDto){
        return commentService.deleteUserComment(commentDto);
    }

    /**
     * 获取评论
     * @param commentDto
     * @return
     */
    @PostMapping("/getComment")
    public Result getComment(@RequestBody CommentDto commentDto){
        return commentService.getComment(commentDto);
    }

    /**
     * 删除所有评论
     * @param commentDto
     * @return
     */
    @PostMapping("/deleteComment")
    public Result deleteComment(@RequestBody CommentDto commentDto){
        return commentService.deleteComment(commentDto.getMaterialId());
    }
}
